<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "pool".
 *
 * @property int $id
 * @property float $v1
 * @property float $v2
 * @property float $v3
 * @property float $v4
 */
class Pool extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'pool';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['v1', 'v2', 'v3', 'v4'], 'number'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'v1' => 'V 1',
            'v2' => 'V 2',
            'v3' => 'V 3',
            'v4' => 'V 4',
        ];
    }

    public static function getLastOne()
    {
        $model = self::find()
            ->orderBy(['id' => SORT_DESC])
            ->one();

        if (!$model) {
            $model = new self();
        }

        return $model;
    }
}
